home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news
- From: enno@inferenzsysteme.informatik.th-darmstadt.de (Enno Sandner)
- Newsgroups: comp.lang.c++
- Subject: Re: delete or delete [] ?
- Date: 02 Apr 1996 20:21:25 +0200
- Organization: Fachbereich Informatik, TH Darmstadt
- Sender: enno@kitz.inferenzsysteme.informatik.th-darmstadt.de
- Message-ID: <ltn34uwkpm.fsf@kitz.inferenzsysteme.informatik.th-darmstadt.de>
- References: <4jp7n7$f8k@mcmail.CIS.McMaster.CA>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- In-reply-to: g9326161@mcmail.cis.McMaster.CA's message of 1 Apr 1996 13:36:23
- -0500
- X-Newsreader: Gnus v5.1
-
- In article <4jp7n7$f8k@mcmail.CIS.McMaster.CA> g9326161@mcmail.cis.McMaster.CA (Hong Shen) writes:
-
- In almost all of C++ literatures, "delete aa" should be used iff aa is not an
- array and "delete [] aa" should be used iff aa is an array. In following case,
- what should I use?
-
- typedef int int10[10];
- int* aa=new int10; // array of 10 integers.
-
- delete aa;
-
- or
-
- delete [] aa;
-
- For gcc (v2.6), it seems that both work. Which is the standard one?
-
- You're allocating an array of int's, thus 'delete[] aa;' is the right
- choice.
-
- Enno
-
-
-